package o;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.PorterDuff.Mode;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SubMenu;
import android.view.View;
import androidx.annotation.LayoutRes;
import androidx.annotation.RestrictTo;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import o.ah.g;

@RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP})
public class az extends MenuInflater {
    static final Class<?>[] ˋ = new Class[]{Context.class};
    static final Class<?>[] ॱ = ˋ;
    Context ˊ;
    final Object[] ˎ = this.ˏ;
    final Object[] ˏ;
    private Object ᐝ;

    static class c implements OnMenuItemClickListener {
        private static final Class<?>[] ॱ = new Class[]{MenuItem.class};
        private Method ˊ;
        private Object ˎ;

        public c(Object obj, String str) {
            this.ˎ = obj;
            Class cls = obj.getClass();
            try {
                this.ˊ = cls.getMethod(str, ॱ);
            } catch (Throwable e) {
                InflateException inflateException = new InflateException("Couldn't resolve menu item onClick handler " + str + " in class " + cls.getName());
                inflateException.initCause(e);
                throw inflateException;
            }
        }

        public boolean onMenuItemClick(MenuItem menuItem) {
            try {
                if (this.ˊ.getReturnType() == Boolean.TYPE) {
                    return ((Boolean) this.ˊ.invoke(this.ˎ, new Object[]{menuItem})).booleanValue();
                }
                this.ˊ.invoke(this.ˎ, new Object[]{menuItem});
                return true;
            } catch (Throwable e) {
                throw new RuntimeException(e);
            }
        }
    }

    class d {
        private int ʻ;
        private int ʻॱ;
        private boolean ʼ;
        private int ʼॱ;
        private int ʽ;
        private int ʽॱ;
        private boolean ʾ;
        private boolean ʿ;
        private boolean ˈ;
        private String ˉ;
        private int ˊ;
        private String ˊˊ;
        private String ˊˋ;
        private int ˊॱ;
        private CharSequence ˊᐝ;
        private Menu ˋ;
        private CharSequence ˋˊ;
        private Mode ˋˋ = null;
        private CharSequence ˋॱ;
        private int ˎ;
        private ColorStateList ˎˎ = null;
        hd ˏ;
        private int ˏॱ;
        private int ͺ;
        final /* synthetic */ az ॱ;
        private CharSequence ॱˊ;
        private int ॱˋ;
        private char ॱˎ;
        private boolean ॱॱ;
        private char ॱᐝ;
        private boolean ᐝ;
        private int ᐝॱ;

        public d(az azVar, Menu menu) {
            this.ॱ = azVar;
            this.ˋ = menu;
            ˋ();
        }

        public void ˋ() {
            this.ˎ = 0;
            this.ˊ = 0;
            this.ʻ = 0;
            this.ʽ = 0;
            this.ॱॱ = true;
            this.ʼ = true;
        }

        public void ˋ(AttributeSet attributeSet) {
            TypedArray obtainStyledAttributes = this.ॱ.ˊ.obtainStyledAttributes(attributeSet, g.ꜝ);
            this.ˎ = obtainStyledAttributes.getResourceId(g.ﹺ, 0);
            this.ˊ = obtainStyledAttributes.getInt(g.ﾟॱ, 0);
            this.ʻ = obtainStyledAttributes.getInt(g.ﹶ, 0);
            this.ʽ = obtainStyledAttributes.getInt(g.ﾞॱ, 0);
            this.ॱॱ = obtainStyledAttributes.getBoolean(g.ʳ, true);
            this.ʼ = obtainStyledAttributes.getBoolean(g.ꞌॱ, true);
            obtainStyledAttributes.recycle();
        }

        public void ˎ(AttributeSet attributeSet) {
            boolean z = true;
            TypedArray obtainStyledAttributes = this.ॱ.ˊ.obtainStyledAttributes(attributeSet, g.ʹॱ);
            this.ͺ = obtainStyledAttributes.getResourceId(g.ʴ, 0);
            this.ˊॱ = (obtainStyledAttributes.getInt(g.ʼʼ, this.ˊ) & -65536) | (obtainStyledAttributes.getInt(g.ʽʻ, this.ʻ) & 65535);
            this.ॱˊ = obtainStyledAttributes.getText(g.ʽʼ);
            this.ˋॱ = obtainStyledAttributes.getText(g.ʼʻ);
            this.ˏॱ = obtainStyledAttributes.getResourceId(g.ʻʽ, 0);
            this.ॱˎ = ˋ(obtainStyledAttributes.getString(g.ʽʽ));
            this.ᐝॱ = obtainStyledAttributes.getInt(g.ʿᐝ, 4096);
            this.ॱᐝ = ˋ(obtainStyledAttributes.getString(g.ʾˋ));
            this.ʻॱ = obtainStyledAttributes.getInt(g.ˆ, 4096);
            if (obtainStyledAttributes.hasValue(g.ʾᐝ)) {
                this.ॱˋ = obtainStyledAttributes.getBoolean(g.ʾᐝ, false) ? 1 : 0;
            } else {
                this.ॱˋ = this.ʽ;
            }
            this.ʿ = obtainStyledAttributes.getBoolean(g.ʻʼ, false);
            this.ʾ = obtainStyledAttributes.getBoolean(g.ʼʽ, this.ॱॱ);
            this.ˈ = obtainStyledAttributes.getBoolean(g.ʻʻ, this.ʼ);
            this.ʼॱ = obtainStyledAttributes.getInt(g.ˈˊ, -1);
            this.ˊˊ = obtainStyledAttributes.getString(g.ʿˊ);
            this.ʽॱ = obtainStyledAttributes.getResourceId(g.ˇ, 0);
            this.ˉ = obtainStyledAttributes.getString(g.ʿˋ);
            this.ˊˋ = obtainStyledAttributes.getString(g.ˈˋ);
            if (this.ˊˋ == null) {
                z = false;
            }
            if (z && this.ʽॱ == 0 && this.ˉ == null) {
                this.ˏ = (hd) ˊ(this.ˊˋ, az.ॱ, this.ॱ.ˎ);
            } else {
                if (z) {
                    Log.w("SupportMenuInflater", "Ignoring attribute 'actionProviderClass'. Action view already specified.");
                }
                this.ˏ = null;
            }
            this.ˋˊ = obtainStyledAttributes.getText(g.ˈᐝ);
            this.ˊᐝ = obtainStyledAttributes.getText(g.ˉˋ);
            if (obtainStyledAttributes.hasValue(g.ˉᐝ)) {
                this.ˋˋ = cl.ˏ(obtainStyledAttributes.getInt(g.ˉᐝ, -1), this.ˋˋ);
            } else {
                this.ˋˋ = null;
            }
            if (obtainStyledAttributes.hasValue(g.ʾˊ)) {
                this.ˎˎ = obtainStyledAttributes.getColorStateList(g.ʾˊ);
            } else {
                this.ˎˎ = null;
            }
            obtainStyledAttributes.recycle();
            this.ᐝ = false;
        }

        private char ˋ(String str) {
            if (str == null) {
                return '\u0000';
            }
            return str.charAt(0);
        }

        private void ˏ(MenuItem menuItem) {
            boolean z = true;
            menuItem.setChecked(this.ʿ).setVisible(this.ʾ).setEnabled(this.ˈ).setCheckable(this.ॱˋ >= 1).setTitleCondensed(this.ˋॱ).setIcon(this.ˏॱ);
            if (this.ʼॱ >= 0) {
                menuItem.setShowAsAction(this.ʼॱ);
            }
            if (this.ˊˊ != null) {
                if (this.ॱ.ˊ.isRestricted()) {
                    throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
                }
                menuItem.setOnMenuItemClickListener(new c(this.ॱ.ˊ(), this.ˊˊ));
            }
            if (menuItem instanceof bj) {
                bj bjVar = (bj) menuItem;
            }
            if (this.ॱˋ >= 2) {
                if (menuItem instanceof bj) {
                    ((bj) menuItem).ॱ(true);
                } else if (menuItem instanceof bi) {
                    ((bi) menuItem).ˏ(true);
                }
            }
            if (this.ˉ != null) {
                menuItem.setActionView((View) ˊ(this.ˉ, az.ˋ, this.ॱ.ˏ));
            } else {
                z = false;
            }
            if (this.ʽॱ > 0) {
                if (z) {
                    Log.w("SupportMenuInflater", "Ignoring attribute 'itemActionViewLayout'. Action view already specified.");
                } else {
                    menuItem.setActionView(this.ʽॱ);
                }
            }
            if (this.ˏ != null) {
                hm.ˊ(menuItem, this.ˏ);
            }
            hm.ॱ(menuItem, this.ˋˊ);
            hm.ˋ(menuItem, this.ˊᐝ);
            hm.ˊ(menuItem, this.ॱˎ, this.ᐝॱ);
            hm.ˏ(menuItem, this.ॱᐝ, this.ʻॱ);
            if (this.ˋˋ != null) {
                hm.ˎ(menuItem, this.ˋˋ);
            }
            if (this.ˎˎ != null) {
                hm.ˏ(menuItem, this.ˎˎ);
            }
        }

        public void ˎ() {
            this.ᐝ = true;
            ˏ(this.ˋ.add(this.ˎ, this.ͺ, this.ˊॱ, this.ॱˊ));
        }

        public SubMenu ˊ() {
            this.ᐝ = true;
            SubMenu addSubMenu = this.ˋ.addSubMenu(this.ˎ, this.ͺ, this.ˊॱ, this.ॱˊ);
            ˏ(addSubMenu.getItem());
            return addSubMenu;
        }

        public boolean ॱ() {
            return this.ᐝ;
        }

        private <T> T ˊ(String str, Class<?>[] clsArr, Object[] objArr) {
            try {
                Constructor constructor = this.ॱ.ˊ.getClassLoader().loadClass(str).getConstructor(clsArr);
                constructor.setAccessible(true);
                return constructor.newInstance(objArr);
            } catch (Throwable e) {
                Log.w("SupportMenuInflater", "Cannot instantiate class: " + str, e);
                return null;
            }
        }
    }

    public az(Context context) {
        super(context);
        this.ˊ = context;
        this.ˏ = new Object[]{context};
    }

    public void inflate(@LayoutRes int i, Menu menu) {
        if (menu instanceof gi) {
            XmlResourceParser xmlResourceParser = null;
            try {
                xmlResourceParser = this.ˊ.getResources().getLayout(i);
                ˋ(xmlResourceParser, Xml.asAttributeSet(xmlResourceParser), menu);
                if (xmlResourceParser != null) {
                    xmlResourceParser.close();
                }
            } catch (Throwable e) {
                throw new InflateException("Error inflating menu XML", e);
            } catch (Throwable e2) {
                throw new InflateException("Error inflating menu XML", e2);
            } catch (Throwable th) {
                if (xmlResourceParser != null) {
                    xmlResourceParser.close();
                }
            }
        } else {
            super.inflate(i, menu);
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void ˋ(org.xmlpull.v1.XmlPullParser r11, android.util.AttributeSet r12, android.view.Menu r13) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException {
        /*
        r10 = this;
        r4 = 0;
        r1 = 1;
        r6 = 0;
        r7 = new o.az$d;
        r7.<init>(r10, r13);
        r0 = r11.getEventType();
    L_0x000c:
        r2 = 2;
        if (r0 != r2) goto L_0x004a;
    L_0x000f:
        r0 = r11.getName();
        r2 = "menu";
        r2 = r0.equals(r2);
        if (r2 == 0) goto L_0x0031;
    L_0x001b:
        r0 = r11.next();
    L_0x001f:
        r2 = r4;
        r5 = r6;
        r3 = r0;
        r0 = r6;
    L_0x0023:
        if (r0 != 0) goto L_0x00dd;
    L_0x0025:
        switch(r3) {
            case 1: goto L_0x00d5;
            case 2: goto L_0x0051;
            case 3: goto L_0x0087;
            default: goto L_0x0028;
        };
    L_0x0028:
        r3 = r5;
    L_0x0029:
        r5 = r11.next();
        r9 = r3;
        r3 = r5;
        r5 = r9;
        goto L_0x0023;
    L_0x0031:
        r1 = new java.lang.RuntimeException;
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r3 = "Expecting menu, got ";
        r2 = r2.append(r3);
        r0 = r2.append(r0);
        r0 = r0.toString();
        r1.<init>(r0);
        throw r1;
    L_0x004a:
        r0 = r11.next();
        if (r0 != r1) goto L_0x000c;
    L_0x0050:
        goto L_0x001f;
    L_0x0051:
        if (r5 == 0) goto L_0x0055;
    L_0x0053:
        r3 = r5;
        goto L_0x0029;
    L_0x0055:
        r3 = r11.getName();
        r8 = "group";
        r8 = r3.equals(r8);
        if (r8 == 0) goto L_0x0066;
    L_0x0061:
        r7.ˋ(r12);
        r3 = r5;
        goto L_0x0029;
    L_0x0066:
        r8 = "item";
        r8 = r3.equals(r8);
        if (r8 == 0) goto L_0x0073;
    L_0x006e:
        r7.ˎ(r12);
        r3 = r5;
        goto L_0x0029;
    L_0x0073:
        r8 = "menu";
        r8 = r3.equals(r8);
        if (r8 == 0) goto L_0x0084;
    L_0x007b:
        r3 = r7.ˊ();
        r10.ˋ(r11, r12, r3);
        r3 = r5;
        goto L_0x0029;
    L_0x0084:
        r2 = r3;
        r3 = r1;
        goto L_0x0029;
    L_0x0087:
        r3 = r11.getName();
        if (r5 == 0) goto L_0x0096;
    L_0x008d:
        r8 = r3.equals(r2);
        if (r8 == 0) goto L_0x0096;
    L_0x0093:
        r2 = r4;
        r3 = r6;
        goto L_0x0029;
    L_0x0096:
        r8 = "group";
        r8 = r3.equals(r8);
        if (r8 == 0) goto L_0x00a3;
    L_0x009e:
        r7.ˋ();
        r3 = r5;
        goto L_0x0029;
    L_0x00a3:
        r8 = "item";
        r8 = r3.equals(r8);
        if (r8 == 0) goto L_0x00c9;
    L_0x00ab:
        r3 = r7.ॱ();
        if (r3 != 0) goto L_0x0028;
    L_0x00b1:
        r3 = r7.ˏ;
        if (r3 == 0) goto L_0x00c3;
    L_0x00b5:
        r3 = r7.ˏ;
        r3 = r3.ॱ();
        if (r3 == 0) goto L_0x00c3;
    L_0x00bd:
        r7.ˊ();
        r3 = r5;
        goto L_0x0029;
    L_0x00c3:
        r7.ˎ();
        r3 = r5;
        goto L_0x0029;
    L_0x00c9:
        r8 = "menu";
        r3 = r3.equals(r8);
        if (r3 == 0) goto L_0x0028;
    L_0x00d1:
        r0 = r1;
        r3 = r5;
        goto L_0x0029;
    L_0x00d5:
        r0 = new java.lang.RuntimeException;
        r1 = "Unexpected end of document";
        r0.<init>(r1);
        throw r0;
    L_0x00dd:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.az.ˋ(org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.view.Menu):void");
    }

    Object ˊ() {
        if (this.ᐝ == null) {
            this.ᐝ = ˋ(this.ˊ);
        }
        return this.ᐝ;
    }

    private Object ˋ(Object obj) {
        if (!(obj instanceof Activity) && (obj instanceof ContextWrapper)) {
            return ˋ(((ContextWrapper) obj).getBaseContext());
        }
        return obj;
    }
}
